package com.pipi.ui.session;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.UUID;

/**
 * Created by pipi on 2017/6/10.
 */
@Controller
@RequestMapping("/session")
public class SessionController {

    @GetMapping
    @ResponseBody
    public String getSessionId(HttpSession session) {
        return session.getId();
    }

    @GetMapping("save")
    @ResponseBody
    public String addSession(HttpSession session,String name,String value){
        session.setAttribute(name, value);
        return "true";
    }

    @GetMapping("{name}")
    @ResponseBody
    String getAttr(@PathVariable("name") String name,HttpSession session){
        return (String)session.getAttribute(name);
    }
}
